package com.lanyou.cook.entity.kettle;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;

import org.springframework.data.jpa.domain.Specification;


@Entity
@Table(name = "R_SLAVE")
public class KettleSlaveServer {

	@Id
	@Column(name="ID_SLAVE")
	private Long id;
	
	private String name;
	
	@Column(name="HOST_NAME")
	private String hostName;
	
	private String port;
	
	@Column(name="MASTER")
	private Boolean isMaster;

	public final static Specification<KettleSlaveServer> EmptySpecification = new Specification<KettleSlaveServer>(){
		@Override
		public Predicate toPredicate(Root<KettleSlaveServer> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
			return null;
		}
	};
	
	public static Specification<KettleSlaveServer> idSpecification(String id){
		return new Specification<KettleSlaveServer>(){
			@Override
			public Predicate toPredicate(Root<KettleSlaveServer> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
				query.where(cb.equal(root.get("id"), id));
				return null;
			}
		};
	}
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getHostName() {
		return hostName;
	}

	public void setHostName(String hostName) {
		this.hostName = hostName;
	}

	public String getPort() {
		return port;
	}

	public void setPort(String port) {
		this.port = port;
	}

	public Boolean getIsMaster() {
		return isMaster;
	}

	public void setIsMaster(Boolean isMaster) {
		this.isMaster = isMaster;
	}
	
}
